// modify-openid.js

var ModifyOpenID = {};

ModifyOpenID.load = function() {
    var rowid = window.arguments[0].id
    var oid = AppalachianDB.getInfo(rowid);
    document.getElementById("openid-url-textbox").value = oid.getURL();
    document.getElementById("openid-use-textbox").value = oid.getUse();
    document.getElementById("openid-url-textbox").focus();
};

ModifyOpenID.unload = function() {
    // do nothing
};

ModifyOpenID.cancel = function() {
    window.close();
};

ModifyOpenID.save = function() {
    var messages = document.getElementById("message-bundle");
    try {
        var url = document.getElementById("openid-url-textbox").value;
        var use = document.getElementById("openid-use-textbox").value;

        if (url == "") {
            alert(messages.getString("blankopenid"));
        } else if (use == "") {
            alert(messages.getString("blankusage"));
        } else {
            document.getElementById("ok-button").disabled = true;
            AppalachianDB.modify(window.arguments[0].id, url, use);
            window.close();
        }
    } catch (e) {
        alert(messages.getString("failure") + " " + e);
    }
};
